using System;
using System.IO;
using System.Web;
using System.Data;
using System.Xml;
using System.Threading;
using System.Collections;
using System.ComponentModel;
using System.Web.Security;
using System.Web.Services;
using ACM.cmsarea08;
using ACM.cmsarea08.Provider;
using System.Web.SessionState;


namespace ACM.cmsarea08.Core {
	public class PrivateLoggerModule :  System.Web.IHttpModule
	{

	public void Init(HttpApplication context)
	  {
	    context.PreRequestHandlerExecute += new EventHandler(context_BeginRequest);
	  }
	
	   void context_BeginRequest(object sender, EventArgs e)
	  {
	/*	   	
	   	HttpContext contesto = null;
	   	if(HttpContext.Current!=null)
	   		contesto = HttpContext.Current;
	   	else 
	   		return;
	   	string path = contesto.Request.Url.AbsolutePath.ToLower();
	   	if(path.IndexOf('?')!=-1)
	   		path = path.Substring(0,path.LastIndexOf('?'));
	   	if(path.IndexOf('&')!=-1)
	   		path = path.Substring(0,path.LastIndexOf('&'));
	   	ACM.cmsarea08.UserLogged urs = (ACM.cmsarea08.Users.CurrentUser!=null?ACM.cmsarea08.Users.CurrentUser:new UserLogged());
	   	
	   	if(path.StartsWith("/administration") && (!path.EndsWith("asmx"))&& urs.Autorizzato==false) {
	   		System.Web.Security.FormsAuthentication.SignOut();
	   		if(contesto.Request.Cookies["UserLang_"+urs.Guid]!=null)
	   			contesto.Request.Cookies["UserLang_"+urs.Guid].Expires = DateTime.Now;
	   		
	   		contesto.Response.Redirect("/default.aspx");
	   	}
	   	//HttpContext.Current.Response.Write("SONO QUI " + HttpContext.Current.Request.Url.AbsolutePath);
	*/   	
	  }	
		public void Dispose()
		{
			//throw new NotImplementedException();
		}
	}
	
}
